package com.saybiu.controller;

import com.saybiu.domain.UserMeta;
import com.saybiu.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author wangwei
 * @Date 2021/4/21 20:02
 * @Version 1.0
 */
//userService.queryUserMeta(user.getUserId());
@RestController
public class UsermetaController {
    @Resource
    private UserService userService;
    /**
     * 查询信息(通过userid)
     * 查询别人信息需要传对方id(get方式)
     * @param beSelectedUserId 被查询人id
     * @param userId 用户自己id
     */
    @GetMapping(value = "/usermetas/{beSelectedUserId}")
    public UserMeta selectUsermeta(@PathVariable("beSelectedUserId")Integer  beSelectedUserId, Integer userId){
        //查询用户信息(别人)
        UserMeta userMeta = userService.queryUserMeta(beSelectedUserId);
        return userMeta;
    }

    //查询用户信息(userid查user)
    /**
     * 查询自己信息
     *  查询自己信息直接token解析id
     * @param userId
     */
    @GetMapping(value = "/usermetas")
    public UserMeta selectUserself(Integer userId){
        //查询用户信息(自己)
        UserMeta userMeta = userService.queryUserMeta(userId);
        return userMeta;
    }
}
